$(document).ready(function(){
	$("#id").on("change", function(){
		var id = $(this).val();
		if(id != 0){
			$.ajax({
				dataType: "json",
				url: "../InformationAnimalServlet",
				data: {animalId: id},
				success: function(data){
					var url = data.photo;
					$('#date_of_birth').html(data.date_of_birth);
					$('#gender').html(data.gender);
					$('#race').html(data.race);
					$('#name').html(data.name);
					$('#last_inoculation').html(data.last_inoculation);
					$('#description').html(data.description);
					$('#img').attr("src", url).fadeIn();
				}
			});
		} else {
			$('#date_of_birth').html("Nie wybrano...");
			$('#gender').html("Nie wybrano...");
			$('#race').html("Nie wybrano...");
			$('#name').html("Nie wybrano...");
			$('#last_inoculation').html("Nie wybrano...");
			$('#description').html("Nie wybrano...");
			$('#img').attr("src", "../Images/picture/brak.jpg").fadeIn();
		}
	});	

});